
    import request from "../util/request";
    type API<T=any>=(...args:T[])=>Promise<any>;

    type LoginParams={

        account:string;
        password:string
    }


    export const loginApi:API<LoginParams> = (body)=>{
        return request("/users/login",{
            method:"post",
            body,
        })
    }
    //添加账号
    type AddAccountParams={
        account:string;
        password:string;
        userGroup:string;
    }
    export const addAccountApi:API<AddAccountParams>  = (body)=>{
        return request("/users/addOrEditAccount",{
             method:"post",
             body
         })
     }
    //获取用户信息
    export const getUserInfoApi:API=()=>{
        return request('/users/getUserInfo')
    }

    //获取账户信息
    type getAccountParams={
        pageSize:number | string,
        pageNumber:number | string,
    }

    export const getAccountListApi:API<getAccountParams>=(body={pageSize:10,pageNumber:1})=>{
        console.log('body',body)
        return request('/users/getAccountList',{
            method:"post",
            body
        })
    }
    //删除账户

    export const delAccountApi:API=(id:string)=>{
        console.log("id",id);
        
        return request('/users/delAccount?id='+id,{
            method:"delete"
        })
    }

    //上传头像
    type saveUserInfo={
        account:string,
    userGroup:string,//角色不可修改	
    imgUrl:string//当前图片的名字
    }


    export const saveUserInfoApi:API<saveUserInfo>=(body)=>{
       
        
        return request('/users/saveUserInfo',{
            method:"post",
            body
        })
    }